-
Notifications
You must be signed in to change notification settings - Fork 14k
Doc: MaybeUninit::assume_init_read Safety: warn on thread safety
#148398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Doc: MaybeUninit::assume_init_read Safety: warn on thread safety
#148398
Conversation
This comment has been minimized.
This comment has been minimized.
Due to `impl<T: Sync> Sync for MaybeUninit<T>`, `MaybeUninit::assume_init_read` is prone to the illegal use transferring ownership of `!Send + Sync` value across threads. This commit adds a warning on this thread safety problem to the method's Safety section. This commit also adds two code examples related to this problem.
bf0ca0c to
1033c71
Compare
MaybeUninit::assume_init_read Safety: warn on thread safetyMaybeUninit::assume_init_read Safety: warn on thread safety (fix of #148083)
MaybeUninit::assume_init_read Safety: warn on thread safety (fix of #148083)MaybeUninit::assume_init_read Safety: warn on thread safety
|
@rustbot label A-docs I-unsound |
|
@rustbot label -I-unsound -I-prioritize |
|
Is it worth adding the following, or something similar?
|
Fixes #148083.
Due to
impl<T: Sync> Sync for MaybeUninit<T>,MaybeUninit::assume_init_readis prone to the illegal use transferring ownership of!Send + Syncvalue across threads. This PR adds a warning on this thread safety problem to the method's Safety section. This PR also adds two code examples related to this problem.On the bad case code example: I wish I could use something better than
MutexGuard<'_, u32>, because I wasn't able to produce Miri-detectable UB.core::sync::Exclusive<&Cell<u32>>would be nice, but it's unstable.